package cloud.kiko.psn.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    //定义交换机
    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("exchange-1");
    }

    //定义队列
    @Bean
    public Queue queue() {
        return new Queue("queue", true);
    }

    //定义绑定关系
    @Bean
    public Binding binding(Queue queue, TopicExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("routing-key-1");
    }

    @Bean
    public Queue queue1() {
        return new Queue("queue-1", true);
    }

    @Bean
    public Binding binding2() {
        return BindingBuilder.bind(queue1()).to(exchange()).with("routing-key-2");
    }
}
